﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TMIS.BLL
{
    public class Thesis
    {
        /// <summary>
        /// 获取题目来源编号
        /// </summary>
        /// <returns></returns>
        public string[] GetTSID()
        {
            DAL.TitleSource dal = DALFactory.DALFactory.CreateTitleSource();
            return dal.Search();
        }
        /// <summary>
        /// 根据题目来源编号获取对应ID号
        /// </summary>
        /// <param name="titlesource"></param>
        /// <returns></returns>
        public Guid GetTSID(string titlesource)
        {
            DAL.TitleSource dal = DALFactory.DALFactory.CreateTitleSource();
            return dal.Search(titlesource);
        }
        /// <summary>
        /// 获取所有教师姓名
        /// </summary>
        /// <returns></returns>
        public string[] GetTeacher()
        {
            DAL.Teacher dal = DALFactory.DALFactory.CreateTeacher();
            return dal.GetName();
        }
        /// <summary>
        /// 获取教师对应ID号
        /// </summary>
        /// <param name="teacher"></param>
        /// <returns></returns>
        public Guid GetTeacherID(string teacher)
        {
            DAL.Teacher dal = DALFactory.DALFactory.CreateTeacher();
            return dal.GetName(teacher);
        }
        /// <summary>
        /// 将论文信息写入到数据库中
        /// </summary>
        /// <param name="thesis"></param>
        public void Insert(Model.Thesis thesis)
        {
            DAL.Thesis dal = DALFactory.DALFactory.CreateThesis();
            dal.Insert(thesis);
        }
        /// <summary>
        /// 检查论文题目是否已经重复
        /// </summary>
        /// <returns></returns>
        public bool Search(string title)
        {
            DAL.Thesis dal = DALFactory.DALFactory.CreateThesis();
            if (dal.Search(title) ==Guid.Empty)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 根据论文ID号删除论文对应信息
        /// </summary>
        /// <param name="guid"></param>
        public void Del(Guid guid)
        {
            DAL.Thesis dal = DALFactory.DALFactory.CreateThesis();
            dal.Del(guid);
        }
    }
}
